package com.pd.business;

import com.pd.constant.SysContants;
import com.pd.pojo.ResponseVo;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by dong peng on 2017/6/11.
 */
@Service("accountBookTypeService")
public class AccountBookTypeService extends BaseService {

    /**
     * 查询用户数据
     *
     * @param inParam
     * @return
     */
    public ResponseVo query(Map inParam){
        List users = dao.selectList("com.pd.pojo.acctbook.selectAcctBookType",inParam);

        ResponseVo responseVo = new ResponseVo();
        responseVo.setCode("0000");
        responseVo.setMsg("调用成功");
        responseVo.setRetData(users);
        return responseVo;
    }

    /**
     * 增加用户数据
     *
     * @param inParam
     * @return
     */
    public ResponseVo add(Map inParam){
        int result = dao.insert("com.pd.pojo.acctbook.insertAcctBookType",inParam);

        ResponseVo responseVo = new ResponseVo();
        if(result == -1) {
            responseVo.setCode(SysContants.ERROR_CODE);
            responseVo.setMsg("新增用户数据失败");
        }else {
            responseVo.setCode(SysContants.SUCCESS_CODE);
            responseVo.setMsg("新增用户数据成功");
        }
        return responseVo;
    }

    /**
     * 修改用户数据
     *
     * @param inParam
     * @return
     */
    public ResponseVo modify(Map inParam){
        int result = dao.update("com.pd.pojo.acctbook.updateAcctBookType",inParam);

        ResponseVo responseVo = new ResponseVo();
        if(result == -1) {
            responseVo.setCode(SysContants.ERROR_CODE);
            responseVo.setMsg("修改用户数据失败");
        }else {
            responseVo.setCode(SysContants.SUCCESS_CODE);
            responseVo.setMsg("修改用户数据成功");
        }
        return responseVo;
    }

    /**
     * 删除用户数据
     *
     * @param inParam
     * @return
     */
    public ResponseVo delete(Map inParam){
        int result = dao.delete("com.pd.pojo.acctbook.deleteAcctBookType",inParam);

        ResponseVo responseVo = new ResponseVo();
        if(result == -1) {
            responseVo.setCode(SysContants.ERROR_CODE);
            responseVo.setMsg("删除用户数据失败");
        }else {
            responseVo.setCode(SysContants.SUCCESS_CODE);
            responseVo.setMsg("删除用户数据成功");
        }
        return responseVo;
    }
}
